#ifdef __cplusplus
extern "C"
{
#endif


#include <pthread.h>
#include "apple.h"
#include "swap.h"

int addvec(number *num)
{
    int sum;
    pthread_rwlock_rdlock(&(num->rwlock));
    sum = num->x + num->y;
    pthread_rwlock_unlock(&(num->rwlock));

    return sum;
}

void swapvec(number *num)
{
    pthread_rwlock_wrlock(&(num->rwlock));
    swap(&num->x, &num->y);
    pthread_rwlock_unlock(&(num->rwlock));
}

#ifdef __cplusplus
}
#endif
